//
//  Card.swift
//  NaiCha
//
//  Created by 唐安坤 on 2024/7/3.
//

import SwiftUI

struct Card: View {
    var body: some View {
        
        VStack {
            ZStack(alignment: .center,content: {
                
                CardView(imageName: "sun.min", title: "嗨！新同学", backColor: .blue, scale: CGSize(width: 1, height: 1), ofset: CGSize(width: 0, height: 0))
                CardView(imageName: "sunset", title: "欢迎学习", backColor: .purple, scale: CGSize(width: 0.98, height: 0.98), ofset: CGSize(width: 0, height: 180))
                CardView(imageName: "moon", title: "我的SwiftUI课程", backColor: .orange, scale: CGSize(width: 0.96, height: 0.96), ofset: CGSize(width: 0, height: 360))
            })
            .padding(EdgeInsets(top: 100, leading: 15, bottom: 15, trailing: 15))
            .frame(maxWidth: .infinity)
            Spacer()
        }
        
    }
}

#Preview {
    Card()
}

private struct CardView: View {
    
    var imageName: String
    var title: String
    var backColor: Color
    var scale:CGSize
    var ofset: CGSize
    
    var body: some View {
        VStack(spacing: 10, content: {
            Image(systemName: imageName).font(.system(size: 30)).foregroundColor(.white)
            Text(title)
                .foregroundColor(.white)
                .font(.system(size: 25,weight: Font.Weight.bold))
        })
        .frame(maxWidth: .infinity,maxHeight: 200)
        .background(backColor)
        .clipShape(RoundedRectangle(cornerRadius: 15.0))
        .scaleEffect(scale)
        .offset(ofset)
        .shadow(color: Color(UIColor(red: 0, green: 0, blue: 0, alpha: 0.4)), radius: 15, x: /*@START_MENU_TOKEN@*/0.0/*@END_MENU_TOKEN@*/, y: 5)
    }
}
